package com.qfjy.homework.zhangquanmin;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author : ZQM
 * @version : 1.0
 * @date : 2022/11/10 19:35
 *
 * 动态生成代理对象的工厂
 */
public class HomeWorkFactory {


    //生成动态代理对象
    public static Object getProxyBean(Object target){
        Class clazz = target.getClass();
        return Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(),
                                        (proxy, method, args) -> method.invoke(target,args));
    }
}
